package com.gzist.elderlyserviceplatform.controller.common;

import com.gzist.elderlyserviceplatform.common.Result;
import com.gzist.elderlyserviceplatform.entity.model.ImageRequestDTO;
import com.gzist.elderlyserviceplatform.service.AiService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * AI功能系列接口层
 */
@Tag(name = "AI功能接口层")
@RestController
@RequestMapping("/api/common/ai")
public class AiController {
    @Autowired
    private AiService aiService;

    /**
     * 生成图片接口
     *
     * @param imageRequestDTO 接口参数，包括图片描述的文本提示词，图片尺寸，输出图片数量等
     * @return List<String> 包含图片 URL 的集合
     */
    @Operation(
            summary = "AI图片生成",
            description = "根据ai提示词进行图片生成"
    )
    @PostMapping("/generateImage")
    public Result<List<String>> generateImage(
            @RequestBody
            @Parameter(description = "接口参数") ImageRequestDTO imageRequestDTO
    ) {
        try {
            return Result.success(aiService.generateImage(imageRequestDTO), "图片生成成功！");
        } catch (Exception e) {
            return Result.error("图片生成失败，请重试");
        }
    }
}